package cn.com.sinux.spring.utils;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.math.RandomUtils;

/**
 * Created by Administrator on 2016/4/7.
 */
public class CodeUtils {

    public static String base64Encode(String input) {
        return new String(Base64.encodeBase64(input.getBytes()));
    }

    public static int getRandomCode(int size){
        return RandomUtils.nextInt(size);
    }

    public static String base64Decode(String input) {
        return new String(Base64.decodeBase64(input));
    }
}
